import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

public class Main {
    private static Random random = new Random();
    private static List<String> problems = new ArrayList<>();
    private static List<Integer> answers = new ArrayList<>();
    private static String generateProblem(List<Integer> answersList) {
        int type = random.nextInt(2);
        int num1 = random.nextInt(100) + 1;
        int num2 = random.nextInt(100) + 1;
        int correctAnswer;
        if (type == 0) {
            correctAnswer = num1 + num2;
        } else {
            // 确保减法结果非负
            if (num1 < num2) {
                int temp = num1;
                num1 = num2;
                num2 = temp;
            }
            correctAnswer = num1 - num2;
        }
        String problem = String.format("%d %s %d =  ", num1, type == 0 ? "+" : "-", num2);
        answersList.add(correctAnswer);
        return problem;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 50; i++) {
            String problem = generateProblem(answers);
            problems.add(problem);
            System.out.println((i + 1) + ". " + problem);
            System.out.print("请输入答案: ");
            int userAnswer = scanner.nextInt();
            int correctAnswer = answers.get(i);
            if (userAnswer == correctAnswer) {
                System.out.println("正确！");
            } else {
                System.out.println("错误，正确答案是: " + correctAnswer);
            }
            scanner.nextLine();
        }
        scanner.close();
    }
}